"""
括号匹配， 一个包含 '(', ')' 和其他字符的字符串，判断该字符串中的括号是否匹配。
"""
from data_structure.stack.stacks import Stack


class Solution:

    def is_valid(self, strings):
        stack = Stack()
        for char in strings:
            if char == "(":
                stack.push(char)
                continue
            if char == ")" and stack.is_empty():
                return False
            if char == ")":
                stack.pop()
        else:
            if stack.is_empty():
                return True
            return False
